<%--
  Created by IntelliJ IDEA.
  User: 14364
  Date: 2023/1/3
  Time: 17:23
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="../static/bootstrap-5.1.3-dist/css/bootstrap.css">
    <script type="text/javascript" src="../static/bootstrap-5.1.3-dist/js/bootstrap.js"></script>
    <title>宠物商品管理</title>
</head>

<style>
    body {
        margin: auto;
        width: 100%;
    }

    .card_d {
        width: 2000px;
        height: 700px;
        background-color: #fffdfd;
        margin-left: 120px;
        margin-top: 30px;
        border-radius: 30px;
        border: none;
        box-shadow: 5px 5px 10px #adabab;
    }

    .operate {
        padding: 20px 50px;
    }

    .operate button {
        border: solid;
        width: 150px;
    }

    .operate a {
        width: 150px;
    }

    .content {
        display: flex;
        justify-content: space-around;
    }

    .card_goods {
        width: 330px;
        height: 450px;
    }

    .card_goods img {
        width: 300px;
        height: 200px;
        margin: 10px 0 10px 15px;

    }

    .card_goods .status {
        margin-top: 50px;
    }

    .page {
        height: 50px;
        width: 1270px;
        position: fixed;
        bottom: 100px;
    }

    li {
        list-style: none;
    }
</style>

<body>
<jsp:include page="../static/Page/Admin/User/head.jsp"/>
<div class="container text-center">
    <div class="row">
        <div class="">
            <jsp:include page="../static/Page/common/AdminNav.jsp"/>
        </div>
        <div class="card_d">
            <div class="tab-pane fade" id="v-pills-profile" role="tabpanel" aria-labelledby="v-pills-profile-tab"
                 tabindex="0"></div>

            <form method="get" action="goods_select" class="operate">
                <div class="row">
                    <div class="col-md-4">
                        <input class="form-control" placeholder="请输入商品名称" name="goodsname" value="${goodsname}">
                    </div>
                    <div class="col-md-2">
                        <button type="submit" class="btn btn-outline-secondary">搜 索</button>
                    </div>
                    <div class="col-md-3" style="margin-left: 300px">
                        <a href="${pageContext.request.contextPath}/admin/goods_add" type="button" class="btn btn-outline-info">上架商品</a>
                    </div>
                </div>
            </form>

            <div class="content">
                <c:forEach items="${goodsList}" var="goods" varStatus="s">
                    <div class="card card_goods">
                        <img class="card-img-top" src="${pageContext.request.contextPath}/display?photo=${goods.photo}">
                        <div class="card-body">
                            <h5 class="card-title">${goods.name}</h5>
                            <div>￥${goods.price}</div>
                            <div>商品描述:${goods.description}</div>

                            <div class="status">

                                <c:if test="${goods.status==1}">
                                    <a class="btn-outline-warning"
                                       href="goods_mod?page=${pageInfo.pageIndex}&goodid=${goods.id}&status=2&goodsname=${goodsname}">修改为无货</a>
                                </c:if>
                                <c:if test="${goods.status==2}">
                                    <a class="btn-outline-success"
                                       href="goods_mod?page=${pageInfo.pageIndex}&goodid=${goods.id}&status=1&goodsname=${goodsname}">修改为有货</a>
                                </c:if>
                                <a class="btn-outline-danger"
                                   href="goods_mod?page=${pageInfo.pageIndex}&goodid=${goods.id}&status=3&goodsname=${goodsname}">下架该商品</a>


                                <c:if test="${goods.status==1}">
                                    <div>该商品货源充足，可以购买</div>
                                </c:if>
                                <c:if test="${goods.status==2}">
                                    <div>该商品暂时无货</div>
                                </c:if>
                            </div>

                        </div>
                    </div>
                </c:forEach>
            </div>


            <div class="page">

                <nav aria-label="Page navigation example">
                    <ul class="pagination justify-content-between">
                        <c:if test="${pageInfo.isLast && falg == null}">
                            <li><a href="goods_list?page=${pageInfo.pageIndex-1}" class="page-link"><span
                                    aria-hidden="true">&larr;</span> 上一页</a></li>
                        </c:if>
                        <c:if test="${pageInfo.isNext && falg == null}">
                            <li><a href="goods_list?page=${pageInfo.pageIndex+1}" class="page-link">下一页 <span
                                    aria-hidden="true">&rarr;</span></a></li>
                        </c:if>
                        <c:if test="${pageInfo.isLast && falg == 1}">
                            <li>
                                <a href="goods_select?page=${pageInfo.pageIndex-1}&goodsname=${goodsname}"
                                   class="page-link"><span aria-hidden="true">&larr;</span> 上一页</a></li>
                        </c:if>
                        <c:if test="${pageInfo.isNext && falg == 1}">
                            <li>
                                <a href="goods_select?page=${pageInfo.pageIndex+1}&goodsname=${goodsname}"
                                   class="page-link">下一页 <span aria-hidden="true">&rarr;</span></a></li>
                        </c:if>

                    </ul>
                    <span>第 ${pageInfo.pageIndex} 页/共 ${pageInfo.sumCount} 页</span>
                </nav>

            </div>


        </div>
    </div>
</div>
</body>
</html>

